from app import app
from models.models import db, UserAuth

with app.app_context():
    db.create_all()
    # 插入测试账号（如不存在时）
    if not UserAuth.query.filter_by(username='admin1').first():
        db.session.add(UserAuth(username='admin1', password='adminpass', role='admin'))
    if not UserAuth.query.filter_by(username='customer1').first():
        db.session.add(UserAuth(username='customer1', password='custpass', role='customer'))
    db.session.commit()
print('数据库初始化完成，测试账号已插入。')  